<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@include file="/WEB-INF/webpage/common/taglibs.jspf"%>
<!DOCTYPE html>
<html lang="en">
<head>
	<title>用户列表</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link type="text/css" rel="stylesheet" href="${staticPath}/layui/css/layui.css">
	<link type="text/css" rel="stylesheet" href="${staticPath}/layui/modules/css/common.css">
	<link type="text/css" rel="stylesheet" href="${staticPath}/layui/modules/css/shop.css">
</head>
<body style="padding:0 30px;">
<blockquote class="layui-elem-quote" style=" border-left: 0px solid #FFFFFF; background-color: #FFFFFF">
	<img src="${staticPath}/layui/modules/images/shop/team.png" style="margin-left: -25px;"> 商户个人中心
</blockquote>
<blockquote class="layui-elem-quote">
	用户管理
</blockquote>
<table class="layui-table" lay-skin="nob">
	<thead>
	<tr>
		<th class="left-margin">客户名</th>
		<th>操作</th>
	</tr>
	</thead>
	<tbody id="view">

	</tbody>
</table>
<div class="shop_button">
	<button class="layui-btn layui-btn-danger" id="addUser">新增客户</button>
</div>
<script src="${staticPath}/layui/layui.js"></script>
<script type="text/javascript">
    layui.use(['jquery','layer','laytpl'], function(){
        var $ = layui.jquery,layer = layui.layer,laytpl = layui.laytpl;
        layer.load(1);
        $.ajax({
            url: '${adminPath}/client/clientuser/ajaxList',
            data:{
                queryFields: 'id,name,'
            },
            type: "POST",
            dataType: "JSON",
            success: function(data){
                layer.closeAll('loading');
                var getTpl = demo.innerHTML,view = document.getElementById('view');
                laytpl(getTpl).render(data, function(html){
                    view.innerHTML = html;
                });
            },
            error: function () {
                layer.closeAll('loading');
                layer.msg("未知错误，请联系管理员！",{icon: 2});
            }
        });
        $("#addUser").bind({
            click:function(){
                $(".layadmin-iframe", window.parent.document).attr("src",'${adminPath}/client/clientuser/create');
            }
        });

        $("#view").on('click', ".row_update",function(){
            $(".layadmin-iframe", window.parent.document).attr("src",'${adminPath}/client/clientuser/'+$(this).attr("row_id")+'/update');
        });
        $("#view").on('click', ".row_delete",function(){
            $.ajax({
                url: '${adminPath}/client/clientuser/'+$(this).attr("row_id")+'/delete',
                data:{
                    'ids':$(this).attr("row_id")
                },
                type: "POST",
                dataType: "JSON",
                success: function(result){
                    layer.closeAll('loading');
                    if(result.ret==0){
                        window.location.reload();
                    }else{
                        layer.alert(result.msg, {icon: 0, title:'警告'});
                    }

                },
                error: function () {
                    layer.closeAll('loading');
                    layer.msg("未知错误，请联系管理员！",{icon: 2});
                }
            });
        });
    });
</script>
<script id="demo" type="text/html">
	<ul class="botton-list">
		{{#  layui.each(d.results, function(index, item){ }}
		<tr>
			<td>{{item.name}}</td>
			<td>
				<div class="layui-btn-group">
					<button class="layui-btn layui-btn-primary layui-btn-sm row_update" style="border: 1px solid #C9C9C9;" row_id="{{item.id}}">
						修改
					</button>
					<button class="layui-btn layui-btn-primary layui-btn-sm row_delete" row_id="{{item.id}}">
						删除
					</button>
				</div>
			</td>
		</tr>
		{{#  }); }}
		{{#  if(d.results.length === 0){ }}
		无数据
		{{#  } }}
	</ul>
</script>
</body>
</html>